package com.google.androidcamp.session4.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

public class CountService extends Service {

    public CountTask mCountTask;

    @Override
    public void onCreate() {
        mCountTask = new CountTask(null);
        mCountTask.execute();
    }

    public class LocalBinder extends Binder {
        CountService getService() {
            return CountService.this;
        }
    }

    private final IBinder mBinder = new LocalBinder();

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    public void setActivity(CountActivity activity) {
        if (mCountTask != null) {
            mCountTask.setActivity(activity);
        }
    }
}